package com.hz.controller;

import com.alibaba.fastjson.JSONObject;
import com.hz.utils.MassageJsons;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/Invite")
public class InviteController {

    @Resource
    StringRedisTemplate stringRedisTemplate;

    //接收邀请人的id和被邀请人的手机号
    @RequestMapping("/getInvitePhone")               //user_pid     user_phone
//    public MassageJsons getInvitePhone(@RequestBody HashMap<String,String> map){
    public MassageJsons getInvitePhone(String user_phone,String user_pid){
       /* System.out.println(map.size());
        //把
        String jsonMap = JSONObject.toJSONString(map);
        stringRedisTemplate.opsForValue().set(map.get("user_phone"),jsonMap,24,TimeUnit.HOURS);*/
       Map<String,String> map =new HashMap<String,String>();
        map.put("user_phone",user_phone);
        map.put("user_pid",user_pid);
        String jsonMap = JSONObject.toJSONString(map);
        stringRedisTemplate.opsForValue().set(map.get("user_phone"),jsonMap,24,TimeUnit.HOURS);
        return new MassageJsons("0","绑定成功");
    }

}
